﻿using Culvert_Help;
using NeXus;
using NeXus.BIMBase;
using NeXus.BIMBase.Core;
using NeXus.BIMBase.SolidCore;
using NeXus.p3d;
using System.Collections.Generic;
using System.Drawing;
using static NeXus.BIMBase.SolidCore.BPSolidBooleanUtil;

namespace checc_baseTools
{
    public class Element_solid
    {

        /// <summary>
        /// 圆锥
        /// </summary>
        /// <param name="radius">半径</param>
        /// <param name="height">高度</param>
        /// <returns></returns>
        public static IGeSolidBase createConeSlope(double radius, double height)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            //声明顶部中心
            GePoint3d centerTop = new GePoint3d(0, 0, height);

            //声明底部中心
            GePoint3d centerbottom = new GePoint3d(0, 0, 0);

            //创建柱体
            GeConeInfo coneInfo = new GeConeInfo(centerbottom, centerTop, radius, 0, true);
            var cone = IGeSolidBase.createGeCone(coneInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(cone);
            graphic.save();
            return cone;
        }

        /// <summary>
        /// 获取圆锥对象
        /// </summary>
        /// <param name="radius">半径</param>
        /// <param name="height">高度</param>
        /// <returns></returns>
        public static IGeSolidBase getCreateConeSlope(double radius, double height)
        {
            //声明顶部中心
            GePoint3d centerTop = new GePoint3d(0, 0, height);

            //声明底部中心
            GePoint3d centerbottom = new GePoint3d(0, 0, 0);

            //创建柱体
            GeConeInfo coneInfo = new GeConeInfo(centerbottom, centerTop, radius, 0, true);
            var cone = IGeSolidBase.createGeCone(coneInfo);
            return cone;
        }

        /// <summary>
        /// 拉伸体
        /// </summary>
        /// <param name="pointS">截面的第一个点</param>
        /// <param name="pointE">截面的第二个点</param>
        /// <param name="pointB">截面的第三个点</param>
        /// <param name="pointT">截面的第四个点</param>
        /// <param name="v3d">拉伸向量</param>
        public static IGeSolidBase TensileBody(GeCurveArray curveList, GeVec3d v3d)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            //拉伸
            GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveList.assembleChains(), v3d, true);
            //参数:拉伸体 返回:一个 IGeSolidBase 
            var solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(solid);
            graphic.save();

            return solid;
        }

        /// <summary>
        /// 拉伸体画笔
        /// </summary>
        /// <param name="pointS">截面的第一个点</param>
        /// <param name="pointE">截面的第二个点</param>
        /// <param name="pointB">截面的第三个点</param>
        /// <param name="pointT">截面的第四个点</param>
        /// <param name="v3d">拉伸向量</param>
        public static BPGraphics TensileBodyBPGraphics(GeCurveArray curveList, GeVec3d v3d)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            //拉伸
            GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveList.assembleChains(), v3d, true);
            //参数:拉伸体 返回:一个 IGeSolidBase 
            var solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(solid);
            return graphic;
        }

        /// <summary>
        /// 获取拉伸体对象
        /// </summary>
        /// <param name="curveList">截面集合</param>
        /// <param name="v3d">拉伸向量</param>
        public static IGeSolidBase getTensileBody(GeCurveArray curveList, GeVec3d v3d)
        {
            //拉伸
            GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveList, v3d, true);
            //参数:拉伸体 返回:一个 IGeSolidBase 
            var solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
            return solid;
        }

        /// <summary>
        /// 获取拉伸体对象
        /// </summary>
        /// <param name="extrusionInfo">拉伸体实体</param>
        public static IGeSolidBase getTensileBody(GeExtrusionInfo extrusionInfo)
        {
            //拉伸
            //参数:拉伸体 返回:一个 IGeSolidBase 
            var solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
            return solid;
        }

        /// <summary>
        /// 球体
        /// </summary>
        /// <param name="radiusZ">Radius：球体半径</param>
        /// <param name="center">center：球体中心</param>
        public static IGeSolidBase Ball(double radiusZ, GePoint3d center)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            GeSphereInfo sphereInfo = new GeSphereInfo(center, radiusZ);
            var sphere = IGeSolidBase.createGeSphere(sphereInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(sphere);
            graphic.save();

            return sphere;
        }

        /// <summary>
        /// 圆柱
        /// </summary>
        /// <param name="radius">底部顶部半径</param>
        /// <param name="height">圆柱高度</param>
        /// <returns></returns>
        public static IGeSolidBase createColumn(double radius, double height)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            GePoint3d centerTop = new GePoint3d(0, 0, height);
            GePoint3d centerbottom = new GePoint3d(0, 0, 0);
            GeConeInfo coneInfo = new GeConeInfo(centerbottom, centerTop, radius, radius, true);
            var cone = IGeSolidBase.createGeCone(coneInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(cone);
            graphic.save();
            return cone;
        }

        /// <summary>
        /// 圆柱画笔
        /// </summary>
        /// <param name="radius">底部顶部半径</param>
        /// <param name="height">圆柱高度</param>
        /// <returns></returns>
        public static BPGraphics createColumnBPGraphics(double radius, double height)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            GePoint3d centerTop = new GePoint3d(0, 0, height);
            GePoint3d centerbottom = new GePoint3d(0, 0, 0);
            GeConeInfo coneInfo = new GeConeInfo(centerbottom, centerTop, radius, radius, true);
            var cone = IGeSolidBase.createGeCone(coneInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(cone);
            return graphic;
        }

        /// <summary>
        /// 获取圆柱对象
        /// </summary>
        /// <param name="radius">底部顶部半径</param>
        /// <param name="height">圆柱高度</param>
        /// <returns></returns>
        public static IGeSolidBase getCreateColumn(double radius, double height)
        {
            GePoint3d centerTop = new GePoint3d(0, 0, height);
            GePoint3d centerbottom = new GePoint3d(0, 0, 0);
            GeConeInfo coneInfo = new GeConeInfo(centerbottom, centerTop, radius, radius, true);
            var cone = IGeSolidBase.createGeCone(coneInfo);

            return cone;
        }
        /// <summary>
        /// 获取柱台锥对象
        /// </summary>
        /// <param name="coneInfo">圆锥体信息</param>
        /// <returns></returns>
        public static IGeSolidBase getCreateConeSlope(GeConeInfo coneInfo)
        {
            var cone = IGeSolidBase.createGeCone(coneInfo);
            return cone;
        }


        /// <summary>
        /// 获取球体对象
        /// </summary>
        /// <param name="radiusZ">Radius：球体半径</param>
        /// <param name="center">center：球体中心</param>
        public static IGeSolidBase getBall(double radiusZ, GePoint3d center)
        {
            GeSphereInfo sphereInfo = new GeSphereInfo(center, radiusZ);
            var sphere = IGeSolidBase.createGeSphere(sphereInfo);

            return sphere;
        }

        /// <summary>
        /// 盒
        /// </summary>
        /// <param name="pointS">底部矩形中心</param>
        /// <param name="pointE">顶部矩形中心</param>
        /// <param name="vectorX">底部所在平面X向量</param>
        /// <param name="vectorY">底部所在平面Y向量</param>
        /// <param name="bottomX">底部X方向长度</param>
        /// <param name="bottomY">底部Y方向长度</param>
        /// <param name="topX">顶部X方向长度</param>
        /// <param name="topY">顶部Y方向长度</param>
        /// <param name="capped">盒体两端是否封闭 默认为:true</param>
        public static IGeSolidBase Box(GePoint3d pointS, GePoint3d pointE, GeVec3d vectorX, GeVec3d vectorY, double bottomX, double bottomY, double topX, double topY, bool capped = true)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            GeBoxInfo boxInfo = new GeBoxInfo(pointS, pointE, vectorX, vectorY, bottomX, bottomY, topX, topY, capped);
            var box = IGeSolidBase.createGeBox(boxInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(box);
            graphic.save();

            return box;
        }

        /// <summary>
        /// 获取盒对象，不绘画
        /// </summary>
        /// <param name="pointS">底部矩形中心</param>
        /// <param name="pointE">顶部矩形中心</param>
        /// <param name="vectorX">底部所在平面X向量</param>
        /// <param name="vectorY">底部所在平面Y向量</param>
        /// <param name="bottomX">底部X方向长度</param>
        /// <param name="bottomY">底部Y方向长度</param>
        /// <param name="topX">顶部X方向长度</param>
        /// <param name="topY">顶部Y方向长度</param>
        /// <param name="capped">盒体两端是否封闭 默认为:true</param>
        public static IGeSolidBase getBox(GePoint3d pointS, GePoint3d pointE, GeVec3d vectorX, GeVec3d vectorY, double bottomX, double bottomY, double topX, double topY, bool capped = true)
        {
            GeBoxInfo boxInfo = new GeBoxInfo(pointS, pointE, vectorX, vectorY, bottomX, bottomY, topX, topY, capped);
            var box = IGeSolidBase.createGeBox(boxInfo);

            return box;
        }

        /// <summary>
        /// 弯管
        /// </summary>
        /// <param name="center">大圆圆心</param>
        /// <param name="vectorX">大圆X向量</param>
        /// <param name="vectorY">大圆Y向量</param>
        /// <param name="majorRadius">大圆半径</param>
        /// <param name="minorRadius">管道半径</param>
        /// <param name="sweepAngle">大圆扫掠角度</param>
        /// <param name="capped">弯管体两端是否封闭 默认为:true</param>
        public static IGeSolidBase Bends(GePoint3d center, GeVec3d vectorX, GeVec3d vectorY, double majorRadius, double minorRadius, double sweepAngle, bool capped = true)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            GeTorusPipeInfo pipeInfo = new GeTorusPipeInfo(center, vectorX, vectorY, majorRadius, minorRadius, sweepAngle, capped);
            var pipe = IGeSolidBase.createGeTorusPipe(pipeInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(pipe);
            graphic.save();

            return pipe;
        }

        /// <summary>
        /// 获取弯管对象
        /// </summary>
        /// <param name="center">大圆圆心</param>
        /// <param name="vectorX">大圆X向量</param>
        /// <param name="vectorY">大圆Y向量</param>
        /// <param name="majorRadius">大圆半径</param>
        /// <param name="minorRadius">管道半径</param>
        /// <param name="sweepAngle">大圆扫掠角度</param>
        /// <param name="capped">弯管体两端是否封闭 默认为:true</param>
        public static IGeSolidBase getBends(GePoint3d center, GeVec3d vectorX, GeVec3d vectorY, double majorRadius, double minorRadius, double sweepAngle, bool capped = true)
        {
            GeTorusPipeInfo pipeInfo = new GeTorusPipeInfo(center, vectorX, vectorY, majorRadius, minorRadius, sweepAngle, capped);
            var pipe = IGeSolidBase.createGeTorusPipe(pipeInfo);

            return pipe;
        }

        /// <summary>
        /// 旋转体
        /// </summary>
        /// <param name="pointS">被旋转的截面的第一个点</param>
        /// <param name="pointE">被旋转的截面的第二个点</param>
        /// <param name="pointC">旋转圆心</param>
        /// <param name="axis">旋转轴</param>
        /// <param name="sweepAngle">旋转角度</param>
        /// <param name="capped">旋转体两端是否封闭 默认为:true</param>

        public static IGeSolidBase RotatingBody(GeCurveArray curveList, GePoint3d pointC, GeVec3d axis, double sweepAngle, bool capped = true)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            //构建旋转体
            GeRotationalSweepInfo sweepInfo = new GeRotationalSweepInfo(curveList.assembleChains(), pointC, axis, sweepAngle, capped);
            var sweep = IGeSolidBase.createGeRotationalSweep(sweepInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(sweep);
            graphic.save();

            return sweep;
        }

        /// <summary>
        /// 获取旋转体对象
        /// </summary>
        /// <param name="curveList">截面</param>
        /// <param name="pointC">旋转圆心</param>
        /// <param name="axis">旋转轴</param>
        /// <param name="sweepAngle">旋转角度</param>
        /// <param name="capped">旋转体两端是否封闭 默认为:true</param>

        public static IGeSolidBase getRotatingBody(GeCurveArray curveList, GePoint3d pointC, GeVec3d axis, double sweepAngle, bool capped = true)
        {
            //构建旋转体
            GeRotationalSweepInfo sweepInfo = new GeRotationalSweepInfo(curveList.assembleChains(), pointC, axis, sweepAngle, capped);
            var sweep = IGeSolidBase.createGeRotationalSweep(sweepInfo);

            return sweep;
        }

        /// <summary>
        /// 扫掠体
        /// </summary>
        /// <param name="pointS">起始端部截面第一个点</param>
        /// <param name="pointE">起始端部截面第二个点</param>
        /// <param name="pointB">起始端部截面第三个点</param>
        /// <param name="pointT">起始端部截面第四个点</param>
        /// <param name="pointS1">尾端截面第一个点</param>
        /// <param name="pointE1">尾端截面第二个点</param>
        /// <param name="pointB1">尾端截面第三个点</param>
        /// <param name="pointT1">尾端截面第四个点</param>
        /// <param name="capped">扫掠体两端是否封闭 默认为:true </param>
        public static IGeSolidBase SweptBody(GeCurveArray curves1, GeCurveArray curves2, bool capped = true)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            List<GeCurveArray> sectionCurves = new List<GeCurveArray>
            {
                //起始端部截面
                curves1,

                //尾端截面
                curves2
            };

            GeRuledSweepInfo sweepInfo = new GeRuledSweepInfo(curves1.assembleChains(), curves2.assembleChains(), capped);
            var sweep = IGeSolidBase.createGeRuledSweep(sweepInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(sweep);
            graphic.save();

            return sweep;
        }

        /// <summary>
        /// 扫掠体
        /// </summary>
        /// <param name="pointS">起始端部截面第一个点</param>
        /// <param name="pointE">起始端部截面第二个点</param>
        /// <param name="pointB">起始端部截面第三个点</param>
        /// <param name="pointT">起始端部截面第四个点</param>
        /// <param name="pointS1">尾端截面第一个点</param>
        /// <param name="pointE1">尾端截面第二个点</param>
        /// <param name="pointB1">尾端截面第三个点</param>
        /// <param name="pointT1">尾端截面第四个点</param>
        /// <param name="capped">扫掠体两端是否封闭 默认为:true </param>
        public static IGeSolidBase SweptBody(List<GeCurveArray> curves, bool capped = true)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            GeCurveArrayCollection curveArrayPtrs = new GeCurveArrayCollection();
            foreach (var item in curves)
            {
                curveArrayPtrs.Add(item.assembleChains());
            }
            GeRuledSweepInfo sweepInfo = new GeRuledSweepInfo(curveArrayPtrs, capped);
            var sweep = IGeSolidBase.createGeRuledSweep(sweepInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(sweep);
            graphic.save();

            return sweep;
        }

        /// <summary>
        /// 获取扫掠体对象
        /// </summary>
        /// <param name="pointS">起始端部截面第一个点</param>
        /// <param name="pointE">起始端部截面第二个点</param>
        /// <param name="pointB">起始端部截面第三个点</param>
        /// <param name="pointT">起始端部截面第四个点</param>
        /// <param name="pointS1">尾端截面第一个点</param>
        /// <param name="pointE1">尾端截面第二个点</param>
        /// <param name="pointB1">尾端截面第三个点</param>
        /// <param name="pointT1">尾端截面第四个点</param>
        /// <param name="capped">扫掠体两端是否封闭 默认为:true </param>
        public static IGeSolidBase getSweptBody(GeCurveArray curves1, GeCurveArray curves2, bool capped = true)
        {
            List<GeCurveArray> sectionCurves = new List<GeCurveArray>();
            //起始端部截面
            sectionCurves.Add(curves1);

            //尾端截面
            sectionCurves.Add(curves2);

            GeRuledSweepInfo sweepInfo = new GeRuledSweepInfo(curves1.assembleChains(), curves2.assembleChains(), capped);
            var sweep = IGeSolidBase.createGeRuledSweep(sweepInfo);

            return sweep;
        }


        /// <summary>
        /// 获取圆锥对象
        /// </summary>
        /// <param name="radius">半径</param>
        /// <param name="height">高度</param>
        /// <param name="rotMatrix">旋转矩阵</param>
        /// <returns></returns>
        public static IGeSolidBase getCreateConeSlope(double radius, double height, GeRotMatrix rotMatrix, GePoint3d center)
        {
            //声明顶部中心
            GePoint3d centerTop = new GePoint3d(center.x, center.y, height);

            //声明底部中心
            GePoint3d centerbottom = center;

            //创建柱体
            GeConeInfo coneInfo = new GeConeInfo(centerbottom, centerTop, rotMatrix, radius, 0, true);
            var cone = IGeSolidBase.createGeCone(coneInfo);
            return cone;
        }

        /// <summary>
        /// 获取圆锥对象
        /// </summary>
        /// <param name="radius">半径</param>
        /// <param name="height">高度</param>
        /// <param name="rotMatrix">旋转矩阵</param>
        /// <returns></returns>
        public static IGeSolidBase getCreateConeSlope(double radius, double height, GePoint3d center)
        {
            //声明顶部中心
            GePoint3d centerTop = new GePoint3d(center.x, center.y, height);

            //声明底部中心
            GePoint3d centerbottom = center;

            //创建柱体
            GeConeInfo coneInfo = new GeConeInfo(centerbottom, centerTop, radius, 0, true);
            var cone = IGeSolidBase.createGeCone(coneInfo);
            return cone;
        }



        /// <summary>
        /// 圆锥
        /// </summary>
        /// <param name="radius">半径</param>
        /// <param name="height">高度</param>
        /// <param name="rotMatrix">旋转矩阵</param>
        /// <param name="center">圆心</param>
        /// <returns></returns>
        public static IGeSolidBase createConeSlope(double radius, double height, GeRotMatrix rotMatrix, GePoint3d center)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            //声明顶部中心
            GePoint3d centerTop = new GePoint3d(center.x, center.y, height);

            //声明底部中心
            GePoint3d centerbottom = center;

            //创建柱体
            GeConeInfo coneInfo = new GeConeInfo(centerbottom, centerTop, rotMatrix, radius, 0, true);
            var cone = IGeSolidBase.createGeCone(coneInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(cone);
            graphic.save();
            return cone;
        }

        /// <summary>
        /// 柱台锥
        /// </summary>
        /// <param name="coneInfo">圆锥体信息</param>
        /// <returns></returns>
        public static IGeSolidBase createConeSlope(GeConeInfo coneInfo)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            var cone = IGeSolidBase.createGeCone(coneInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(cone);
            graphic.save();
            return cone;
        }

        /// <summary>
        /// 拉伸体
        /// </summary>
        /// <param name="extrusionInfo">拉伸体实体</param>
        /// <returns></returns>
        public static IGeSolidBase TensileBody(GeExtrusionInfo extrusionInfo)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            //参数:拉伸体 返回:一个 IGeSolidBase 
            var solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(solid);
            graphic.save();

            return solid;
        }

        /// <summary>
        /// 球体
        /// </summary>
        /// <param name="sphereInfo">球体实体</param>
        /// <returns></returns>
        public static IGeSolidBase wingWall(GeSphereInfo sphereInfo)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            var sphere = IGeSolidBase.createGeSphere(sphereInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(sphere);
            graphic.save();

            return sphere;
        }

        /// <summary>
        /// 盒
        /// </summary>
        /// <param name="boxInfo">盒实体</param>
        /// <returns></returns>
        public static IGeSolidBase Box(GeBoxInfo boxInfo)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            var box = IGeSolidBase.createGeBox(boxInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(box);
            graphic.save();

            return box;
        }

        /// <summary>
        /// 弯管
        /// </summary>
        /// <param name="pipeInfo">弯管实体</param>
        /// <returns></returns>
        public static IGeSolidBase Bends(GeTorusPipeInfo pipeInfo)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            var pipe = IGeSolidBase.createGeTorusPipe(pipeInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(pipe);
            graphic.save();

            return pipe;
        }

        /// <summary>
        /// 旋转体
        /// </summary>
        /// <param name="sweepInfo">旋转体实体</param>
        /// <returns></returns>
        public static IGeSolidBase RotatingBody(GeRotationalSweepInfo sweepInfo)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            //构建旋转体
            var sweep = IGeSolidBase.createGeRotationalSweep(sweepInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(sweep);
            graphic.save();

            return sweep;
        }
        /// <summary>
        /// 扫掠体
        /// </summary>
        /// <param name="sweepInfo">扫掠体实体</param>
        /// <returns></returns>
        public static IGeSolidBase SweptBody(GeRuledSweepInfo sweepInfo)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            var sweep = IGeSolidBase.createGeRuledSweep(sweepInfo);
            BPGraphics graphic = model.createPhysicalGraphics();
            graphic.addSolid(sweep);
            graphic.save();

            return sweep;
        }

        /// <summary>
        /// 布尔合集(isSave) 返回布尔后的元素
        /// </summary>
        /// <param name="geSolidBase1">目标集</param>
        /// <param name="geSolidBase2">操作集</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的图素</returns>
        public static BPGraphics BoolCollection(IGeSolidBase geSolidBase1, IGeSolidBase geSolidBase2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //构建几何实体
            BPGraphics graphic1 = model.createPhysicalGraphics();
            graphic1.addSolid(geSolidBase1);

            BPGraphics graphic2 = model.createPhysicalGraphics();
            graphic2.addSolid(geSolidBase2);
            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Unite);
            
            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }

        ///// <summary>
        ///// 布尔合集(isSave)
        ///// </summary>
        ///// <param name="graphic1">目标集</param>
        ///// <param name="geSolidBase2">操作集</param>
        ///// <param name="isSave">是否返回</param>
        ///// <returns>布尔后的元素</returns>
        //public static BPGraphics BoolCollection(BPGraphics graphic1, IGeSolidBase geSolidBase2, bool isSave)
        //{
        //    BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
        //    BPModelBase model = project.getActiveModel();

        //    //构建几何实体
        //    BPGraphics graphic2 = model.createPhysicalGraphics();
        //    graphic1.addSolid(geSolidBase2);

        //    //布尔计算
        //    BPGraphics graphicBool = model.createPhysicalGraphics();

        //    int tolerance = 0;
        //    BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
        //    BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
        //    int status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Unite);
        //    if (isSave)
        //    {
        //        graphicBool.save();
        //    }
        //    return graphicBool;
        //}

        /// <summary>
        /// 布尔合集(isSave)
        /// </summary>
        /// <param name="graphic1">目标集</param>
        /// <param name="graphic2">操作集</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的元素</returns>
        public static BPGraphics BoolCollection(BPGraphics graphic1, BPGraphics graphic2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Unite);
            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔合集，并设置颜色和材质
        /// </summary>
        /// <param name="geSolidBase1">第一个几何实体</param>
        /// <param name="geSolidBase2">第二个几何实体</param>
        public static BPGraphics BoolCollection(IGeSolidBase geSolidBase1, IGeSolidBase geSolidBase2, Color color, BPMaterial material, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //构建几何实体
            BPGraphics graphic1 = model.createPhysicalGraphics();
            graphic1.addSolid(geSolidBase1);


            BPGraphics graphic2 = model.createPhysicalGraphics();
            graphic2.addSolid(geSolidBase2);

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Unite);

            if (isSave)
            {
                graphicBool.save();
                //修改材质
                BPMaterial.setMaterialToEntity(graphicBool.getEntityR(), material, true);
                //BPMaterial.updateMaterial(material, false, true, true, doc);
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔合集(isSave)
        /// </summary>
        /// <param name="graphic1">目标集</param>
        /// <param name="graphic2">操作集</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的元素</returns>
        public static BPGraphics BoolCollection(BPGraphics graphic1, IGeSolidBase geSolidBase2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            //构建几何实体
            //构建几何实体
            BPGraphics graphic2 = model.createPhysicalGraphics();
            graphic2.addSolid(geSolidBase2);
            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Unite);
            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔合集(isSave)
        /// </summary>
        /// <param name="graphic1">目标集</param>
        /// <param name="graphic2">操作集</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的元素</returns>
        public static BPGraphics BoolCollection(BPEntity graphic1, IGeSolidBase geSolidBase2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            //构建几何实体
            //构建几何实体
            BPGraphics graphic2 = model.createPhysicalGraphics();
            graphic2.addSolid(geSolidBase2);
            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2.getEntityR(), BPBooleanOp.Unite);
            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔合集(isSave)
        /// </summary>
        /// <param name="graphic1">目标集</param>
        /// <param name="graphic2">操作集</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的元素</returns>
        public static BPGraphics BoolCollection(BPEntity graphic1, BPEntity graphic2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();
            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Unite);
            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }
        ///// <summary>
        ///// 查看几何实体属于哪个子类实体
        ///// </summary>
        ///// <param name="geSolidBase">几何实体</param>
        ///// <param name="Type">实体的类型</param>
        ///// <param name="solid1">返回子类几何实体对象</param>
        ///// <returns></returns>
        //public static IGeSolidBase SwitchType(IGeSolidBase geSolidBase)
        //{
        //    IGeSolidBase solid = null;
        //    var Type = geSolidBase.solidType;
        //    switch (Type)
        //    {
        //        case GeSolidBaseType.TorusPipe:
        //            solid = createTorusPipe(geSolidBase.getGeTorusPipeInfo());
        //            break;

        //        case GeSolidBaseType.Cone:
        //            solid = createCone(geSolidBase.getGeConeInfo());
        //            break;

        //        case GeSolidBaseType.Box:
        //            solid = createBox(geSolidBase.getGeBoxInfo());
        //            break;

        //        case GeSolidBaseType.Sphere:
        //            solid = createSphere(geSolidBase.getGeSphereInfo());
        //            break;

        //        case GeSolidBaseType.Extrusion:
        //            solid = createExtrusion(geSolidBase.getGeExtrusionInfo());
        //            break;

        //        case GeSolidBaseType.RotationalSweep:
        //            solid = createRotationalSweep(geSolidBase.getGeRotationalSweepInfo());
        //            break;

        //        case GeSolidBaseType.RuledSweep:
        //            solid = createRuledSweep(geSolidBase.getGeRuledSweepInfo());
        //            break;
        //    }

        //    return solid;
        //}

        /// <summary>
        /// 布尔差集(isSave) 用于返回布尔后的实体再操作
        /// </summary>
        /// <param name="geSolidBase1">目标集</param>
        /// <param name="geSolidBase2">操作集</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的图素</returns>
        public static BPGraphics BoolDifferenceSet(IGeSolidBase geSolidBase1, IGeSolidBase geSolidBase2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //构建几何实体
            BPGraphics graphic1 = model.createPhysicalGraphics();
            graphic1.addSolid(geSolidBase1);

            BPGraphics graphic2 = model.createPhysicalGraphics();
            graphic2.addSolid(geSolidBase2);

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Substract);
            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔差集(isSave)
        /// </summary>
        /// <param name="graphic1">目标集</param>
        /// <param name="geSolidBase2">操作集</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的图素</returns>
        public static BPGraphics BoolDifferenceSet(BPGraphics graphic1, IGeSolidBase geSolidBase2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //构建几何实体
            BPGraphics graphic2 = model.createPhysicalGraphics();
            graphic2.addSolid(geSolidBase2);

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Substract);

            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔差集(isSave)
        /// </summary>
        /// <param name="graphic1">目标集</param>
        /// <param name="geSolidBase2">操作集</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的图素</returns>
        public static BPGraphics BoolDifferenceSet(IGeSolidBase geSolidBase1, BPGraphics graphic2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //构建几何实体
            BPGraphics graphic1 = model.createPhysicalGraphics();
            graphic1.addSolid(geSolidBase1);

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Substract);

            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔差集(isSave)
        /// </summary>
        /// <param name="graphic1">目标集</param>
        /// <param name="geSolidBase2">操作集</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的图素</returns>
        public static BPGraphics BoolDifferenceSet(BPGraphics graphic1, BPGraphics graphic2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Substract);

            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }
        /// <summary>
        /// 两个图素布尔差集(isSave)
        /// </summary>
        /// <param name="graphic1">目标集</param>
        /// <param name="graphic2">操作集</param>
        /// <param name="material">材质</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的图素</returns>
        public static BPGraphics BoolDifferenceSet(BPGraphics graphic1, BPGraphics graphic2, BPMaterial material, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Substract);

            if (isSave)
            {
                //ElementAttribute.SettingMaterial(graphicResult, material);
                graphicBool.save();
                //修改材质
                BPMaterial.setMaterialToEntity(graphicBool.getEntityR(), material, true);
                //BPMaterial.updateMaterial(material, false, true, true, doc);
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔差集并修改颜色附材质
        /// </summary>
        /// <param name="geSolidBase1">第一个几何实体</param>
        /// <param name="geSolidBase2">第二个几何实体</param>
        /// <param name="color">颜色</param>
        /// <param name="material2">材质</param>
        public static BPGraphics BoolDifferenceSet(IGeSolidBase geSolidBase1, IGeSolidBase geSolidBase2, Color color, BPMaterial material, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //构建几何实体
            BPGraphics graphic1 = model.createPhysicalGraphics();
            graphic1.addSolid(geSolidBase1);

            BPGraphics graphic2 = model.createPhysicalGraphics();
            graphic2.addSolid(geSolidBase2);
            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Substract);

            if (isSave)
            {
                graphicBool.save();
                //修改材质
                BPMaterial.setMaterialToEntity(graphicBool.getEntityR(), material, true);
                //BPMaterial.updateMaterial(material, false, true, true, doc);
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔交集(isSave) 用于返回布尔后的实体再操作
        /// </summary>
        /// <param name="geSolidBase1">目标集</param>
        /// <param name="geSolidBase2">操作集</param>
        /// <param name="isSave">是否返回</param>
        /// <returns>布尔后的图素</returns>
        public static BPGraphics BoolIntersections(IGeSolidBase geSolidBase1, IGeSolidBase geSolidBase2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //构建几何实体
            BPGraphics graphic1 = model.createPhysicalGraphics();
            graphic1.addSolid(geSolidBase1);

            BPGraphics graphic2 = model.createPhysicalGraphics();
            graphic2.addSolid(geSolidBase2);

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Intersection);

            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔交集(isSave)
        /// </summary>
        /// <param name="graphic1">目标集</param>
        /// <param name="geSolidBase2">操作集</param>
        /// <returns>布尔后的图素</returns>
        public static BPGraphics BoolIntersections(BPGraphics graphic1, IGeSolidBase geSolidBase2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            BPGraphics graphic2 = model.createPhysicalGraphics();
            graphic2.addSolid(geSolidBase2);

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Intersection);

            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }

        /// <summary>
        /// 布尔交集(isSave)
        /// </summary>
        /// <param name="graphic1">目标集</param>
        /// <param name="graphic2">操作集</param>
        /// <returns>布尔后的图素</returns>
        public static BPGraphics BoolIntersections(BPGraphics graphic1, BPGraphics graphic2, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Intersection);

            if (isSave)
            {
                graphicBool.save();
            }
            return graphicBool;
        }
        
        /// <summary>
        /// 布尔交集并修改颜色并附材质
        /// </summary>
        /// <param name="geSolidBase1">第一个几何实体</param>
        /// <param name="geSolidBase2">第二个几何实体</param>
        /// <param name="material">材质</param>
        public static BPGraphics BoolIntersections(IGeSolidBase geSolidBase1, IGeSolidBase geSolidBase2, Color color, BPMaterial material, bool isSave)
        {
            BPProject project = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = project.getActiveModel();

            //构建几何实体
            BPGraphics graphic1 = model.createPhysicalGraphics();
            graphic1.addSolid(geSolidBase1);

            BPGraphics graphic2 = model.createPhysicalGraphics();
            graphic2.addSolid(geSolidBase2);

            //布尔计算
            BPGraphics graphicBool = model.createPhysicalGraphics();

            int tolerance = 0;
            BPSolidBooleanUtil.getAngleTolerance(ref tolerance);
            BPSolidBooleanUtil.setAngleTolerance(36);//布尔前将精度设置为36，防止布尔导致的面片变形
            P3DStatus status = BPSolidBooleanUtil.doBoolean(graphicBool, graphic1, graphic2, BPBooleanOp.Intersection);

            if (isSave)
            {
                //ElementAttribute.SettingMaterial(graphicResult, material);
                graphicBool.save();
                //修改材质
                BPMaterial.setMaterialToEntity(graphicBool.getEntityR(), material, true);
                //BPMaterial.updateMaterial(material, false, true, true, doc);
            }
            return graphicBool;
        }

        ///// <summary>
        ///// solid转polyface
        ///// </summary>
        //public static void AddPolyface(IGeSolidBase geSolidBase)
        //{
        //    BPGraphics graphic = BPApplication.getInstance().getProjectManager().getActiveModel().createPhysicalGraphics();
        //    graphic.addSolid(geSolidBase);

        //    List<PolyfaceHandle> listPoly = BPMeshMeans.convertToMesh(graphic, 8);
        //    BPGraphics graphic2 = BPApplication.getInstance().getProjectManager().getActiveModel().createPhysicalGraphics();
        //    foreach (var poly in listPoly)
        //    {
        //        graphic2.addPolyface(poly);
        //    }
        //    graphic2.save();
        //}
    }
}
